package com.group3.hospital.controller;

import com.group3.hospital.bean.Dep;
import com.group3.hospital.bean.Doctor;
import com.group3.hospital.bean.Subject;
import com.group3.hospital.service.DoctorService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @author 秀秀
 */
@Controller
public class DoctorController {

    @Resource
    private DoctorService doctorService;

    //显示医生介绍的画面
    @RequestMapping("/doctorUi")
    public String doctorUi(Integer subjectId, Model model){
        List<Subject> nodeps = new ArrayList<>();
        List<Subject> odeps = new ArrayList<>();
        List<Subject> dideps = new ArrayList<>();

        List<Doctor> ks1 = new ArrayList<>();
        List<Doctor> ks2 = new ArrayList<>();
        List<Doctor> ks3 = new ArrayList<>();

        try {
            nodeps = doctorService.querySubByDepId1();
            odeps = doctorService.querySubByDepId2();
            dideps = doctorService.querySubByDepId3();

            ks1 = doctorService.queryDocByDepAndSub1();
            ks2 = doctorService.queryDocByDepAndSub2();
            ks3 = doctorService.queryDocByDepAndSub3();

        } catch (Exception e) {
            e.printStackTrace();
        }

        model.addAttribute("nodeps",nodeps);
        model.addAttribute("odeps",odeps);
        model.addAttribute("dideps",dideps);

        model.addAttribute("ks1",ks1);
        model.addAttribute("ks2",ks2);
        model.addAttribute("ks3",ks3);

        return "doctor";
    }

}
